﻿using Abp.Domain.Repositories;
using Abp.Domain.Services;
using System;
using System.Threading.Tasks;
/****************************************************************
*   作者：CZ
*   CLR版本：4.0.30319.42000
*   创建时间：2018/5/29 17:00:12
*   2018
*   描述说明：留言管理领域服务
*
*   修改历史：
*
*
*****************************************************************/
namespace Mt.Site.Core.Messages_
{
    public class MessagesManager : DomainService, IMessagesManager
    {
        private IRepository<Messages, Guid> _messagesRepositor;                                 // 公共仓储

        /// <summary>
        /// 自动注入仓储
        /// </summary>
        /// <param name="messagesRepositor"></param>
        public MessagesManager(IRepository<Messages, Guid> messagesRepositor)
        {
            _messagesRepositor = messagesRepositor;
        }

        /// <summary>
        /// 创建并获取Id
        /// </summary>
        /// <param name="messages">信息记录</param>
        /// <returns>Id</returns>
        public async Task<Guid> CreateAndGetIdAsync(Messages messages)
        {
            return await _messagesRepositor.InsertAndGetIdAsync(messages);
        }

        /// <summary>
        /// 创建并返回实体
        /// </summary>
        /// <param name="messages">信息记录</param>
        /// <returns>实体</returns>
        public async Task<Messages> CreateAsync(Messages messages)
        {
            return await _messagesRepositor.InsertAsync(messages);
        }

        /// <summary>
        /// 更新记录信息
        /// </summary>
        /// <param name="messages">信息记录</param>
        /// <returns>实体</returns>
        public async Task<Messages> UpdateAsync(Messages messages)
        {
            return await _messagesRepositor.UpdateAsync(messages);
        }

        /// <summary>
        /// 更新记录信息并返回Id
        /// </summary>
        /// <param name="messages">信息记录</param>
        /// <returns>Id</returns>
        public async Task<Guid> UpdateAndGetIdAsync(Messages messages)
        {
            return await _messagesRepositor.InsertOrUpdateAndGetIdAsync(messages);
        }

        /// <summary>
        /// 删除记录信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task DeleteAsync(Guid Id)
        {
            await _messagesRepositor.DeleteAsync(Id);
        }
    }
}
